package celiasoft.itasalib.query;

import android.graphics.Bitmap;
import celiasoft.itasalib.filegatherer.ImageGatherer;
import celiasoft.itasalib.query.result.QueryResult;
import celiasoft.itasalib.query.resultparser.IQueryResultParser;
import celiasoft.itasalib.staticdata.ItasaStaticUrls;
import celiasoft.itasalib.structures.DataElement;

public class ShowThumbQuery extends Query {

	private ImageGatherer _gatherer;
	
	public ShowThumbQuery(ImageGatherer gatherer, String apikey) {
		super(null, apikey);
		this._gatherer = gatherer;
	}
	
	public ShowThumbQuery(ImageGatherer gatherer, String apikey, int id) {
		super(null, apikey);
		this._gatherer = gatherer;
		this.setShowId(id);
	}

	@Override
	public QueryResult execute() {
		return null;
	}

	@Override
	public DataElement getFirstResult() {
		return null;
	}

	@Override
	public Bitmap getImageResult() {
		String queryUrl = this.getQueryUrl().replaceAll("&$", "");
		
		if(queryUrl != null){
			return _gatherer.getBitmap(queryUrl);
		}
		
		return null;
	}


	private int _id;


	@Override
	protected String getQueryUrl() {
		return String.format(ItasaStaticUrls.SHOWS_THUMB_URL, this._id, getAPIKey());
	}

	public int getShowId(){
		return this._id;
	}
	
	public void setShowId(int id){
		this._id = id;
	}
	
	
	@Override
	protected IQueryResultParser getResultParser() {
		// no needed
		return null;
	}

	
}
